package com.jinxin.platform.cdcardpassmgr.controller;

import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.cdcardpassmgr.rpc.CdcardpassmgrRpc;
import com.jinxin.platform.cdcardpassmgr.service.ICardpassmgrRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * All rights Reserved, Designed By www.beonelot.com
 *
 * @version: V1.0
 * @Copyright: www.beonelot.com Inc. All rights reserved.
 * @Description：
 * @Date: 2020-12-26
 * @Author: Lingnan
 **/
@RestController
@RequestMapping("/cardpassmgrRecord")
@Slf4j
public class CardpassmgrRecordController {
    @Autowired
    private ICardpassmgrRecordService recordService;
    @Autowired
    private CdcardpassmgrRpc cdcardpassmgrRpc;

    @RequestMapping("/list")
    public Map<String,Object> list(@RequestParam int page, @RequestParam int limit,String projectId,
                                   String cardNum,String typeId,String carNum,String direction,
                                   String startDate,String endDate){
        HashMap param = new HashMap();
        param.put("page", page);
        param.put("limit", limit);
        param.put("projectId", projectId);
        param.put("cardNum", cardNum);
        param.put("typeId", typeId);
        param.put("carNum", carNum);
        param.put("startDate", startDate);
        param.put("endDate", endDate);
        if(!StringUtils.isEmpty(direction)){
            param.put("direction", Integer.parseInt(direction));
        }
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("code",0);
        resultMap.put("msg","");
        resultMap.put("count", recordService.listPageCount(param));
        resultMap.put("data", recordService.listPage(param));
        return resultMap;
    }

    @GetMapping("/delete")
    public JsonResult delete(String id){
        return recordService.delete(id);
    }


}
